﻿/*
Copyright (c) 2008 William Duff

Permission is hereby granted, free of charge, to any person obtaining a copy 
of this software and associated documentation files (the "Software"), to deal 
in the Software without restriction, including without limitation the rights 
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all 
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
SOFTWARE.
*/

using System;
using System.Collections.Generic;
using System.Text;

namespace LiveUpload.Facebook
{
    /// <summary>
    /// Data related to a person tag.
    /// </summary>
    public class PersonTag : IComparable<PersonTag>
    {
        #region Constructors

        /// <summary>
        /// Constructs a new person tag object
        /// </summary>
        public PersonTag(string name)
        {
            this.name = name;
            this.x = 0f;
            this.y = 0f;
            this.imagePath = string.Empty;
        }

        /// <summary>
        /// Constructs a new person tag object.
        /// </summary>
        public PersonTag(string name, float left, float top, float width, float height, string imagePath)
        {
            this.name = name;
            this.left = left;
            this.top = top;
            this.width = width;
            this.height = height;
            this.imagePath = imagePath;

            // The scale used by Facebook is 0.0 to 100.0 and photo gallery uses 0.0 to 1.0.
            this.x = (width / 2.0f + left) * 100;
            this.y = (height / 2.0f + top) * 100;
        }

        #endregion

        #region Private Fields
        
        private string name;
        private float left;
        private float top;
        private float width;
        private float height;
        private string imagePath;
        private float x;
        private float y;

        #endregion

        #region Public Fields

        /// <summary>
        /// Name of this person tag.
        /// </summary>
        public string Name
        {
            get { return this.name; }
        }

        /// <summary>
        /// X coordinate of the left of the tag as a percentage of the width of the image. Ranges from 0.0 to 1.0.
        /// </summary>
        public float Left
        {
            get { return this.left; }
        }

        /// <summary>
        /// Y coordinate of the top of the tag as a percentage of the height of the image. Ranges from 0.0 to 1.0.
        /// </summary>
        public float Top
        {
            get { return this.top; }
        }

        /// <summary>
        /// Width of the tag as a percentage of the width of the image. Ranges from 0.0 to 1.0.
        /// </summary>
        public float Width
        {
            get { return this.width; }
        }

        /// <summary>
        /// Height of the tag as a percentage of the height of the image. Ranges from 0.0 to 1.0.
        /// </summary>
        public float Height
        {
            get { return this.height; }
        }

        /// <summary>
        /// Path to the tagged image.
        /// </summary>
        public string ImagePath
        {
            get { return this.imagePath; }
        }

        /// <summary>
        /// X coordinate of the center of the tag as a percentage of the width of the image. Ranges from 0.0 to 100.0.
        /// </summary>
        public float X
        {
            get { return this.x; }
        }

        /// <summary>
        /// Y coordinate of the center of the tag as a percentage of the height of the image. Ranges from 0.0 to 100.0.
        /// </summary>
        public float Y
        {
            get { return this.y; }
        }

        #endregion

        #region IComparable<PersonTag> Members

        public int CompareTo(PersonTag other)
        {
            return String.Compare(this.name, other.Name, true);
        }

        #endregion
    }
}
